<?php

namespace App\Http\Requests;

use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Exceptions\HttpResponseException;

class ExperReplyUser extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'expert_cons_id' => 'required',
            'content' => 'required',
        ];
    }

    public function messages()
    {
        return [
            'expert_cons_id.required' => '请选择问诊记录',
            'content.required' => '请输入内容',
        ];
    }

    protected function failedValidation(Validator $validator)
    {
        throw new HttpResponseException(response()->json([
            "code"  => 500,
            "msg"   => $validator->getMessageBag()->first(),
            "data"  => null,
        ], 200, [
            'Content-Type'=>'application/json; charset=UTF-8'
        ]));
    }
}
